package kr.saeildadim.androidexam_saeildamil.chapter8;

import kr.saeildadim.androidexam_saeildamil.chapter7.MyView;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Toast;

public class handlerOrder extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View view = new MyView(this);
		
		view.setOnTouchListener(new OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if(event.getAction()==MotionEvent.ACTION_DOWN){
					Toast.makeText(handlerOrder.this, "Listener : touch", Toast.LENGTH_LONG).show();
					//return true;
				}
			return false;
			}
		});
		setContentView(view);
	}
	
	public class Myview extends View{

		public Myview(Context context) {
			super(context);
		}
		public boolean onTouchEvent(MotionEvent event){
			if(event.getAction()==MotionEvent.ACTION_DOWN){
				Toast.makeText(handlerOrder.this, "View : touch", Toast.LENGTH_LONG).show();
				//return true;
			}
		return false;
		}
		
	}
	public boolean onTouchEvent(MotionEvent event){
		if(event.getAction()==MotionEvent.ACTION_DOWN){
			Toast.makeText(handlerOrder.this, "Activity : touch", Toast.LENGTH_LONG).show();
			return true;
		}
	return false;
	}

}
